import math

#------------------------------------------------------------------------------
# Name: AssaultMarine
# Desc: klasa wektora + dzialania na wektorach
#------------------------------------------------------------------------------


class Vector:
    
    x = 0.0
    y = 0.0
    
    def __init__( self, _x, _y ):
        self.x = _x
        self.y = _y
        
    def add (self, vector):
        return Vector(self.x + vector.x, self.y + vector.y)
    
    def subtract (self, vector):
        return Vector (self.x - vector.x, self.y - vector.y)
    
    def multiple (self, m):
        return Vector(m*self.x, m*self.y)
    
    def divide (self, m):
        return Vector(self.x/m,self.y/m)
    
    def length (self):
        return math.sqrt(self.x*self.x + self.y*self.y)
    
    def normalize (self):
        return Vector(self.x/self.length(), self.y/self.length())
    
    def angle (self):
        return math.acos(Vector(0.0, self.y).length() / self.length()) * 180.0 / math.pi
    
    def cutTo(self, length):
        if (self.length() > length):
            return self.normalize().multiple(length)
        else:
            return self